package com.vm.action;

import com.vm.common.MD5;
import com.vm.dao.system.IUser;
import com.vm.entity.Menu;
import com.vm.entity.User;

/***
 * @description 登陆管理
 * 
 * **/

@SuppressWarnings("serial")
public class LoginAction extends ActionSuper {
	private String name;
	private String pwd;
	private IUser userDAO;
	private User user;

	public String index() throws Exception {
		name = "admin";
		pwd = "123456";
		this.getSession().clear();
		return "input";
	}

	public String login() throws Exception {
//		if (name == null || "".equals(name)) {
//			this.addFieldError("nameErr", super.getText("login_err"));
//			return INPUT;
//		}
//		System.out.println("ddddddddddddddddd");
//		if (pwd == null || "".equals(pwd)) {
//			this.addFieldError("nameErr", super.getText("login_err"));
//			return INPUT;
//		}
//		String password = MD5.encode(pwd);
//		user = userDAO.validator(name, password);
//		if (null == user) {
//			this.addFieldError("nameErr", super.getText("login_err"));
//			return INPUT;
//		}
//
//		if (user.getRlGrp() != null && !user.isSuperAdmin()) {
//			// 得到具体用户拥有的菜单
//			String roleGrps = userDAO.getAllGrp(user.getRlGrp());
//			// 角色ID存入user对象中
//			user.setRoleId(userDAO.getUserRoleID(user.getRlGrp(),user));
//			// 存入user对象拥有哪些菜单值
//			user.setMenuGrpId(roleGrps);
//		}
//		super.getSession().put("user", user);
		return SUCCESS;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPwd() {
		return pwd;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}

	public IUser getUserDAO() {
		return userDAO;
	}

	public void setUserDAO(IUser userDAO) {
		this.userDAO = userDAO;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}
}
